<template>
  <div class="table-box table-content">
    <div class="btn">
      <el-button type="primary" @click="saveRule">保存</el-button>
    </div>
    <div class="main">
      <div class="base">
        <h3>基本信息</h3>
        <el-form label-position="left" label-width="auto">
          <el-form-item label="名称">
            <el-input v-model="name" placeholder="请输入名称"></el-input>
          </el-form-item>
          <el-form-item label="执行次数(数值大先执行)">
            <el-input v-model="salience" placeholder="0~100"></el-input>
          </el-form-item>
          <el-form-item label="规则描述">
            <el-input v-model="description" placeholder="请输入描述"></el-input>
          </el-form-item>
          <el-form-item label="规则包">
            <el-input v-model="packageName" @click="getPackage" :disabled="true"></el-input>
          </el-form-item>
        </el-form>
        <el-dialog v-model="dialogVisible" title="流程规则列表" width="80%" :before-close="handleClose">
          <ProTable
            ref="proTable"
            :columns="columns"
            :request-api="getRulePackage"
            :init-param="initParam"
            :request-auto="true"
            :data-callback="dataCallback"
            :search-col="{ xs: 1, sm: 1, md: 1, lg: 1, xl: 1 }"
          >
            <template #operation="scope">
              <el-button type="primary" :icon="Select" @click="choosePackage(scope)">选择</el-button>
            </template>
          </ProTable>
        </el-dialog>
      </div>
      <div class="detailInfo">
        <h3>详细信息</h3>
        <el-tabs>
          <el-tab-pane label="条件集">
            <el-form>
              <el-form-item label="规则详细:">
                <el-select
                  v-model="constraint.beforePropertyName"
                  style="width: 130px; margin-right: 20px"
                  placeholder="Select"
                  size="large"
                  @change="beforePropertyNameChange"
                >
                  <el-option v-for="item in serviceRuleOptions" :key="item.value" :label="item.label" :value="item.value" />
                </el-select>
                <el-select
                  v-if="
                    constraint.beforePropertyName == `etitle` ||
                    constraint.beforePropertyName == `edesc` ||
                    constraint.beforePropertyName == `processKey`
                  "
                  v-model="constraint.afterPropertyName"
                  style="width: 130px; margin-right: 20px"
                  placeholder="Select"
                  size="large"
                >
                  <el-option v-for="item in conditionOptionsAll" :key="item.value" :label="item.label" :value="item.value" />
                </el-select>
                <el-select
                  v-if="
                    constraint.beforePropertyName != `etitle` &&
                    constraint.beforePropertyName != `edesc` &&
                    constraint.beforePropertyName != `processKey`
                  "
                  v-model="constraint.afterPropertyName"
                  style="width: 130px; margin-right: 20px"
                  placeholder="Select"
                  size="large"
                >
                  <el-option v-for="item in conditionOptions" :key="item.value" :label="item.label" :value="item.value" />
                </el-select>
                <div v-if="constraint.beforePropertyName == `etitle` || constraint.beforePropertyName == `edesc`">
                  <el-input v-model="constraint.propertyValueName" style="width: 180px; margin-right: 20px" />
                </div>
                <div v-if="constraint.beforePropertyName == `createdByNo`">
                  <el-input
                    v-model="constraint.propertyValueName"
                    @click="dialogRuleRequestNoTableVisible = true"
                    style="width: 180px; margin-right: 20px"
                  />
                  <el-dialog title="选择用户" v-model="dialogRuleRequestNoTableVisible">
                    <div :style="{ height: '500px' }">
                      <Userselect @send-data="sendRuleRequestNoData" />
                    </div>
                  </el-dialog>
                </div>
                <div
                  v-if="
                    constraint.beforePropertyName == `priorityNo` ||
                    constraint.beforePropertyName == `seriousnessNo` ||
                    constraint.beforePropertyName == `effectRangeNo` ||
                    constraint.beforePropertyName == `levelNo` ||
                    constraint.beforePropertyName == `imodeNo` ||
                    constraint.beforePropertyName == `requestCategoryNo` ||
                    constraint.beforePropertyName == `organizationNos` ||
                    constraint.beforePropertyName == `cicategoryNos` ||
                    constraint.beforePropertyName == `serviceDirIds` ||
                    constraint.beforePropertyName == `technologyGroup` ||
                    constraint.beforePropertyName == `locationNos`
                  "
                >
                  <el-tree-select
                    style="width: 180px; margin-right: 20px"
                    v-model="prioritySelectValue"
                    :data="prioritySelectList"
                    multiple
                    :render-after-expand="false"
                    show-checkbox
                    check-strictly
                    check-on-click-node
                  />
                </div>
                <div v-if="constraint.beforePropertyName == `processKey`">
                  <el-tree-select
                    style="width: 180px; margin-right: 20px"
                    v-model="prioritySelectValue"
                    :data="prioritySelectList"
                    :render-after-expand="false"
                    show-checkbox
                    check-strictly
                    check-on-click-node
                  />
                </div>
                <div v-if="constraint.beforePropertyName == `companyNo`">
                  <el-input
                    v-model="constraint.propertyValueName"
                    @click="dialogRuleCompanyNoTableVisible = true"
                    style="width: 180px; margin-right: 20px"
                  />
                  <el-dialog title="选择客户" v-model="dialogRuleCompanyNoTableVisible">
                    <div :style="{ height: '500px' }">
                      <CustemerSelect @send-data="sendRuleCompanyNoData" />
                    </div>
                  </el-dialog>
                </div>
                <el-button type="primary" @click="addRule"> 添加 </el-button>
              </el-form-item>
              <el-form-item class="item" label="连接方式:">
                <el-radio v-model="constraint.andOr" label="and">and</el-radio>
                <el-radio v-model="constraint.andOr" label="or">or</el-radio>
              </el-form-item>
            </el-form>
            <ProTable
              ref="ruleProTable"
              row-key="id"
              :indent="20"
              :data="constraintsList"
              :columns="ruleColumns"
              :search-col="{ xs: 1, sm: 1, md: 2, lg: 3, xl: 3 }"
            >
              <!-- 表格操作 -->
              <template #operation="scope">
                <el-button type="primary" link @click="toUp(scope.$index)">上移</el-button>
                <el-button type="primary" link @click="toDown(scope.$index)">下移</el-button>
                <el-button type="primary" link @click="deleteRule(scope.$index)">删除</el-button>
              </template>
            </ProTable>
          </el-tab-pane>
          <el-tab-pane label="动作集">
            <el-form>
              <el-form-item label="动作类型:">
                <el-select
                  v-model="executeActionName"
                  placehoder="请选择"
                  size="large"
                  style="width: 180px; margin-right: 20px"
                  @change="selectActionType"
                >
                  <el-option v-for="item in executeAction" :key="item.value" :label="item.name" :value="item.value" />
                </el-select>
              </el-form-item>
              <el-form-item label="动作详细:">
                <el-cascader
                  v-if="actionType === 'servicesNo' || actionType === 'assigneeGroupNo'"
                  v-model="orgName"
                  :options="orgList"
                  :show-all-levels="false"
                  placeholder="所属技术组"
                  @update:model-value="getVal"
                  :props="props1"
                />
                <el-cascader
                  v-if="actionType === 'requestCategoryNo' || actionType === 'serviceDirIdsStr'"
                  v-model="requestType"
                  :options="orgList"
                  :show-all-levels="false"
                  placeholder="选择分类"
                  @update:model-value="getVal"
                  :props="props2"
                />
                <div v-if="actionType === 'approvalNo' || actionType === 'technicianNo'">
                  <el-input
                    v-model="approval.name"
                    @click="dialogRuleRequestNoTableVisible_action = true"
                    style="width: 180px; margin-right: 20px"
                  />
                  <el-dialog title="选择用户" v-model="dialogRuleRequestNoTableVisible_action">
                    <div :style="{ height: '500px' }">
                      <Userselect @send-data="sendRuleRequestNoData_action" />
                    </div>
                  </el-dialog>
                </div>
                <div
                  v-if="
                    actionType === 'updateLevelNo' ||
                    actionType === 'priorityNo' ||
                    actionType === 'seriousnessNo' ||
                    actionType === 'effectRangeNo' ||
                    actionType === 'processKey' ||
                    actionType === 'attendance' ||
                    actionType === 'automaticallyAssigned' ||
                    actionType === 'variablesAssigneeType' ||
                    actionType === 'requestClose'
                  "
                >
                  <el-select v-model="selectText" style="width: 180px; margin-right: 20px" @change="selectTextChange">
                    <el-option v-for="item in selectValue" :key="item.value" :label="item.name" :value="item.value"></el-option>
                  </el-select>
                </div>
                <div v-if="actionType === 'slaContractNo'">
                  <el-input v-model="SLA.SLAName" @click="slaDialog = true" style="width: 180px; margin-right: 20px" />
                  <el-dialog title="选择SLA" v-model="slaDialog">
                    <ProTable
                      ref="ruleProTable"
                      row-key="id"
                      :indent="20"
                      :data="SLAList"
                      :columns="SLAColumns"
                      :search-col="{ xs: 1, sm: 1, md: 2, lg: 3, xl: 3 }"
                    >
                      <!-- 表格操作 -->
                      <template #operation="scope">
                        <el-button type="primary" link @click="chooseSLA(scope)">选择</el-button>
                      </template>
                    </ProTable>
                  </el-dialog>
                </div>
                <el-button type="primary" style="margin-left: 20px" @click="addAction">添加</el-button>
              </el-form-item>
            </el-form>
            <ProTable
              ref="ruleProTable"
              row-key="id"
              :indent="20"
              :data="actionList"
              :columns="actionColumns"
              :search-col="{ xs: 1, sm: 1, md: 2, lg: 3, xl: 3 }"
            >
              <!-- 表格操作 -->
              <template #operation="scope">
                <el-button type="primary" link @click="deleteAction(scope.$index)">删除</el-button>
              </template>
            </ProTable>
          </el-tab-pane>
        </el-tabs>
      </div>
    </div>
  </div>
</template>
<script setup lang="ts" name="editRules">
import { useRoute, useRouter } from "vue-router";
import { onMounted, ref, reactive } from "vue";
import { ElMessage, FormItemProps, FormProps, ElMessageBox } from "element-plus";
import { ProTableInstance, ColumnProps, HeaderRenderScope } from "@/components/ProTable/interface";
import { Select } from "@element-plus/icons-vue";
import ProTable from "@/components/ProTable/index.vue";
import { getRulePackage } from "@/api/modules/dictionary";
import Userselect from "@/views/tools/userselect/index.vue";
import CustemerSelect from "@/views/tools/custemerSelect/index.vue";
import { dataDictionaryItemsfindByCode, getCategoryTreeAllData } from "@/api/modules/dataDictionary";
import { getUserDepartment } from "@/api/modules/jggl";
import { ResServiceList } from "@/api/modules/serviceList";
import { findPageProcessDefinitions, getConfigurationCategoryTreeAllData } from "@/api/modules/slaProtocolManagement";
import { getPriority, getUrgency, getImpact, getProcess, getRequestCategory } from "@/api/modules/dataDictionary";
import { getClassification, getServiceCatalog, getSLAList } from "@/api/modules/dictionary";
import { getUpgradeUserList, getEditReqestRuleData, checkRuleName, addBusinessRule, saveUpdateRule } from "@/api/modules/rule";
onMounted(async () => {
  console.log(route);
  const routeParams = {
    ruleNo: route.query.ruleNo,
    packageNo: route.query.packageNo,
    flag: "changeApproval"
  };
  const res = (await getEditReqestRuleData(routeParams)) as any;
  console.log(res);
  name.value = res?.ruleName;
  salience.value = res?.salience;
  description.value = res?.description;
  packageNo.value = res.rulePackageDTO.rulePackageNo;
  packageName.value = res.rulePackageDTO.packageName;
  rulePatternNo.value = res.conditionDTO.rulePatternNo;
  res.ruleConstraintDTOList.forEach(item => {
    if (item.propertyName === "etitle matches") {
      item.propertyNameLable = "标题 包含";
    }
    if (item.propertyName === "etitle not matches") {
      item.propertyNameLable = "标题 不包含";
    }
    if (item.propertyName === "etitle ==") {
      item.propertyNameLable = "标题 等于";
    }
    if (item.propertyName === "etitle !=") {
      item.propertyNameLable = "标题 不等于";
    }
    if (item.propertyName === "etitle start") {
      item.propertyNameLable = "标题 开始字符";
    }
    if (item.propertyName === "etitle end") {
      item.propertyNameLable = "标题 结束字符";
    }

    if (item.propertyName === "edesc matches") {
      item.propertyNameLable = "描述 包含";
    }
    if (item.propertyName === "edesc not matches") {
      item.propertyNameLable = "描述 不包含";
    }
    if (item.propertyName === "edesc ==") {
      item.propertyNameLable = "描述 等于";
    }
    if (item.propertyName === "edesc !=") {
      item.propertyNameLable = "描述 不等于";
    }
    if (item.propertyName === "edesc start") {
      item.propertyNameLable = "描述 开始字符";
    }
    if (item.propertyName === "edesc end") {
      item.propertyNameLable = "描述 结束字符";
    }

    if (item.propertyName === "createdByNo in") {
      item.propertyNameLable = "请求人 包含";
    }
    if (item.propertyName === "createdByNo notIn") {
      item.propertyNameLable = "请求人 不包含";
    }

    if (item.propertyName === "priorityNo in") {
      item.propertyNameLable = "优先级 包含";
    }
    if (item.propertyName === "priorityNo notIn") {
      item.propertyNameLable = "优先级 不包含";
    }

    if (item.propertyName === "seriousnessNo in") {
      item.propertyNameLable = "紧急度 包含";
    }
    if (item.propertyName === "seriousnessNo notIn") {
      item.propertyNameLable = "紧急度 不包含";
    }

    if (item.propertyName === "effectRangeNo in") {
      item.propertyNameLable = "影响范围 包含";
    }
    if (item.propertyName === "effectRangeNo notIn") {
      item.propertyNameLable = "影响范围 不包含";
    }

    if (item.propertyName === "requestCategoryNo in") {
      item.propertyNameLable = "分类 包含";
    }
    if (item.propertyName === "requestCategoryNo notIn") {
      item.propertyNameLable = "分类 不包含";
    }

    if (item.propertyName === "levelNo in") {
      item.propertyNameLable = "级别 包含";
    }
    if (item.propertyName === "levelNo notIn") {
      item.propertyNameLable = "级别 不包含";
    }

    if (item.propertyName === "imodeNo in") {
      item.propertyNameLable = "来源 包含";
    }
    if (item.propertyName === "imodeNo notIn") {
      item.propertyNameLable = "来源 不包含";
    }

    if (item.propertyName === "organizationNos in") {
      item.propertyNameLable = "请求人所属机构 包含";
    }
    if (item.propertyName === "organizationNos notIn") {
      item.propertyNameLable = "请求人所属机构 不包含";
    }

    if (item.propertyName === "processKey matches") {
      item.propertyNameLable = "流程 包含";
    }
    if (item.propertyName === "processKey not matches") {
      item.propertyNameLable = "流程 不包含";
    }
    if (item.propertyName === "processKey ==") {
      item.propertyNameLable = "流程 等于";
    }
    if (item.propertyName === "processKey !=") {
      item.propertyNameLable = "流程 不等于";
    }
    if (item.propertyName === "processKey start") {
      item.propertyNameLable = "流程 开始字符";
    }
    if (item.propertyName === "processKey end") {
      item.propertyNameLable = "流程 结束字符";
    }

    if (item.propertyName === "companyNo in") {
      item.propertyNameLable = "请求所属客户 包含";
    }
    if (item.propertyName === "companyNo notIn") {
      item.propertyNameLable = "请求所属客户 不包含";
    }

    if (item.propertyName === "cicategoryNos in") {
      item.propertyNameLable = "配置项分类 包含";
    }
    if (item.propertyName === "cicategoryNos notIn") {
      item.propertyNameLable = "配置项分类 不包含";
    }

    if (item.propertyName === "serviceDirIds in") {
      item.propertyNameLable = "关联服务 包含";
    }
    if (item.propertyName === "serviceDirIds notIn") {
      item.propertyNameLable = "关联服务 不包含";
    }

    if (item.propertyName === "weekNo in") {
      item.propertyNameLable = "创建时间所属星期 包含";
    }
    if (item.propertyName === "weekNo notIn") {
      item.propertyNameLable = "创建时间所属星期 不包含";
    }

    if (item.propertyName === "technologyGroup in") {
      item.propertyNameLable = "请求人所属技术组 包含";
    }
    if (item.propertyName === "technologyGroup notIn") {
      item.propertyNameLable = "请求人所属技术组 不包含";
    }

    if (item.propertyName === "locationNos in") {
      item.propertyNameLable = "地点 包含";
    }
    if (item.propertyName === "locationNos notIn") {
      item.propertyNameLable = "地点 不包含";
    }
    // item.propertyValueName = item.propertyValue.replace(/\.\*/g, "");
    // item.propertyValueName=item.propertyValueName;
    constraintsList.value.push(item);
  });
  res.ruleActionDTOList.forEach(item => {
    if (item.propertyName === "servicesNo") {
      item.propertyNameLable = "设置服务机构";
    }

    if (item.propertyName === "approvalNo") {
      item.propertyNameLable = "设置审批人";
    }

    if (item.propertyName === "updateLevelNo") {
      item.propertyNameLable = "升级到";
    }

    if (item.propertyName === "assigneeGroupNo") {
      item.propertyNameLable = "指派工作组";
    }

    if (item.propertyName === "technicianNo") {
      item.propertyNameLable = "指派工程师";
    }

    if (item.propertyName === "priorityNo") {
      item.propertyNameLable = "设置优先级";
    }

    if (item.propertyName === "seriousnessNo") {
      item.propertyNameLable = "设置紧急度";
    }

    if (item.propertyName === "effectRangeNo") {
      item.propertyNameLable = "设置影响范围";
    }

    if (item.propertyName === "processKey") {
      item.propertyNameLable = "设置流程";
    }

    if (item.propertyName === "requestCategoryNo") {
      item.propertyNameLable = "设置分类";
    }

    if (item.propertyName === "serviceDirIdsStr") {
      item.propertyNameLable = "关联服务";
    }

    if (item.propertyName === "slaContractNo") {
      item.propertyNameLable = "匹配SLA";
    }

    if (item.propertyName === "attendance") {
      item.propertyNameLable = "按排班处理";
    }

    if (item.propertyName === "automaticallyAssigned") {
      item.propertyNameLable = "根据繁忙程度自动指派技术员";
    }

    if (item.propertyName === "variablesAssigneeType") {
      item.propertyNameLable = "变量指派";
    }

    if (item.propertyName === "requestClose") {
      item.propertyNameLable = "关闭请求";
    }
    actionList.value.push(item);
  });
  console.log(constraintsList.value, actionList.value);
});
const router = useRouter();
const route = useRoute();
const rulePatternNo = ref();
const proTable = ref<ProTableInstance>();
const name = ref("");
const executeActionName = ref("");
const salience = ref("");
const description = ref("");
const packageName = ref("");
const initParam = reactive({
  "rulePackageDto.module": "request"
});
const dialogVisible = ref(false);
const columns = reactive<ColumnProps<any>[]>([
  {
    prop: "rulePackageNo",
    label: "id"
  },
  {
    prop: "packageName",
    label: "规则包名称",
    sortable: true,
    search: {
      el: "input",
      tooltip: "输入规则包名称",
      label: "规则包名称",
      key: "rulePackageDto.packageName"
    }
  },
  {
    prop: "flagName",
    label: "类型",
    sortable: true,
    render(h) {
      switch (h.row.flagName) {
        case "requestProce":
          return "请求流程流转中触发";
        case "saveChange":
          return "[System] 变更新增时触发";
        case "changeProce":
          return "变更流程流转中触发";
        case "saveRequest":
          return "[System] 请求新增时触发";
        default:
          return "";
      }
    },
    enum: [
      {
        genderLabel: "请求新增时触发",
        genderValue: "requestProce"
      },
      {
        genderLabel: "变更新增时触发",
        genderValue: "saveChange"
      },
      {
        genderLabel: "请求流程流转中触发",
        genderValue: "requestProce"
      },
      {
        genderLabel: "变更流程流转中触发",
        genderValue: "changeProce"
      }
    ],
    fieldNames: { label: "genderLabel", value: "genderValue" },
    search: {
      el: "select",
      tooltip: "输入类型名称",
      label: "类型",
      key: "rulePackageDto.flagName",
      props: { filterable: true }
    }
  },
  {
    prop: "rulePackageRemarks",
    label: "别名",
    sortable: true,
    search: {
      el: "input",
      tooltip: "输入别名",
      label: "规则包备注",
      key: "rulePackageDto.rulePackageRemarks"
    }
  },
  { prop: "operation", label: "操作" }
]);
const ruleColumns = reactive<ColumnProps<ResServiceList>[]>([
  { prop: "propertyNameLable", label: "条件", sortable: true },
  { prop: "propertyValueName", label: "规则内容", sortable: true, width: 260 },
  { prop: "andOr", label: "连接方式", sortable: true, width: 260 },
  { prop: "operation", label: "操作", fixed: "right", width: 200 }
]);
const SLAColumns = reactive<ColumnProps<any>[]>([
  { prop: "agreement", label: "名称", sortable: true },
  { prop: "beginTime", label: "开始时间", sortable: true },
  { prop: "endTime", label: "截至时间", sortable: true },
  { prop: "operation", label: "操作", fixed: "right" }
]);
const actionColumns = reactive<ColumnProps<any>[]>([
  { prop: "propertyNameLable", label: "动作类型", sortable: true },
  { prop: "givenName", label: "动作详细", sortable: true },
  { prop: "operation", label: "操作", fixed: "right" }
]);
const dataCallback = (data: any) => {
  return {
    list: data.data,
    total: data.totalSize,
    pageNum: data.page,
    pageSize: data.rows
  };
};
const getPackage = e => {
  dialogVisible.value = true;
  initParam["rulePackageDto.module"] = "request";
};
//弹出框操作
const handleClose = (done: () => void) => {
  ElMessageBox.confirm("确定退出吗?")
    .then(() => {
      done();
    })
    .catch(() => {
      // catch error
    });
};
//
const packageNo = ref("");
const choosePackage = scope => {
  console.log(scope);
  dialogVisible.value = false;
  packageName.value = scope.row.packageName;
  packageNo.value = scope.row.rulePackageNo;
};
const constraint = reactive({
  beforePropertyName: "etitle",
  afterPropertyName: "matches",
  conNo: "",
  propertyNameLable: "",
  propertyName: "",
  propertyValue: "",
  propertyValueName: "",
  // dataType: "",
  andOr: "and",
  sequence: 1
});
//服务水平部分开始
const serviceRuleOptions = [
  {
    value: "etitle",
    label: "标题"
  },
  {
    value: "edesc",
    label: "描述"
  },
  {
    value: "createdByNo",
    label: "请求人"
  },
  {
    value: "priorityNo",
    label: "优先级"
  },
  {
    value: "seriousnessNo",
    label: "紧急度"
  },
  {
    value: "effectRangeNo",
    label: "影响范围"
  },
  {
    value: "requestCategoryNo",
    label: "分类"
  },
  {
    value: "levelNo",
    label: "级别"
  },
  {
    value: "imodeNo",
    label: "来源"
  },
  {
    value: "organizationNos",
    label: "请求人所属机构"
  },
  {
    value: "processKey",
    label: "流程"
  },
  {
    value: "companyNo",
    label: "请求所属客户"
  },
  {
    value: "cicategoryNos",
    label: "配置项分类"
  },
  {
    value: "serviceDirIds",
    label: "关联服务"
  },
  {
    value: "weekNo",
    label: "创建时间所属星期"
  },
  {
    value: "technologyGroup",
    label: "请求人所属技术组"
  },
  {
    value: "locationNos",
    label: "地点"
  }
];
const conditionOptionsAll = [
  {
    value: "matches",
    label: "包含"
  },
  {
    value: "not matches",
    label: "不包含"
  },
  {
    value: "==",
    label: "等于"
  },
  {
    value: "!=",
    label: "不等于"
  },
  {
    value: "matches start",
    label: "开始字符"
  },
  {
    value: "matches end",
    label: "结束字符"
  }
];
const conditionOptions = [
  {
    value: "in",
    label: "包含"
  },
  {
    value: "notIn",
    label: "不包含"
  }
];
const dialogRuleRequestNoTableVisible = ref(false);
const dialogRuleRequestNoTableVisible_action = ref(false);
//用户选择子组件弹窗回调方法
const sendRuleRequestNoData = (data: any) => {
  dialogRuleRequestNoTableVisible.value = false;
  constraint.propertyValue = data.userId;
  constraint.propertyValueName = data.fullName;
};
const sendRuleRequestNoData_action = (data: any) => {
  dialogRuleRequestNoTableVisible_action.value = false;
  approval.name = data.fullName;
  approval.userId = data.userId;
};
const prioritySelectValue = ref();
const prioritySelectList = ref<any>([]);
const dialogRuleCompanyNoTableVisible = ref(false);
//客户选择子组件弹窗回调方法
const sendRuleCompanyNoData = (data: any) => {
  dialogRuleCompanyNoTableVisible.value = false;
  constraint.propertyValue = data.orgNo;
  constraint.propertyValueName = data.orgName;
};

// 上移
const toUp = async (index: any) => {
  if (index == 0) return;
  constraintsList.value[index] = constraintsList.value.splice(index - 1, 1, constraintsList.value[index])[0];
};
// 下移
const toDown = async (index: any) => {
  if (index === constraintsList.value.length - 1) return;
  // 将上下个数组元素值替换为当前元素值，并将被替换的元素值赋值给当前元素
  constraintsList.value[index] = constraintsList.value.splice(index + 1, 1, constraintsList.value[index])[0];
};
// 删除
const deleteRule = async (index: any) => {
  constraintsList.value.splice(index, 1);
};
const deleteAction = async (index: any) => {
  actionList.value.splice(index, 1);
};
interface TreeNode {
  value: any;
  lable: any;
  children?: TreeNode[];
  id: string;
  name: string;
  attr: any;
  data: any;
}
function traverseTree(node: TreeNode, callback: (node: TreeNode) => void) {
  callback(node);
  if (node.children) {
    node.children.forEach(child => traverseTree(child, callback));
  }
}
//选择条件改变方法
const beforePropertyNameChange = (data: any) => {
  prioritySelectValue.value = [];
  constraint.propertyValueName = "";
  constraint.propertyValue = "";
  if (data != `etitle` && data != `edesc` && data != `processKey`) {
    constraint.afterPropertyName = "in";
  } else {
    constraint.afterPropertyName = "matches";
  }
  if (data == "priorityNo") {
    dataDictionaryItemsfindByCode("priority").then(res => {
      (res as any).forEach(function (element) {
        element["lable"] = element["dname"];
        element["value"] = element["dname"];
      });
      prioritySelectList.value = res as any;
    });
  }
  if (data == "seriousnessNo") {
    dataDictionaryItemsfindByCode("seriousness").then(res => {
      (res as any).forEach(function (element) {
        element["lable"] = element["dname"];
        element["value"] = element["dname"];
      });
      prioritySelectList.value = res as any;
    });
  }
  if (data == "effectRangeNo") {
    dataDictionaryItemsfindByCode("effectRange").then(res => {
      (res as any).forEach(function (element) {
        element["lable"] = element["dname"];
        element["value"] = element["dname"];
      });
      prioritySelectList.value = res as any;
    });
  }
  if (data == "levelNo") {
    dataDictionaryItemsfindByCode("level").then(res => {
      (res as any).forEach(function (element) {
        element["lable"] = element["dname"];
        element["value"] = element["dname"];
      });
      prioritySelectList.value = res as any;
    });
  }
  if (data == "imodeNo") {
    dataDictionaryItemsfindByCode("imode").then(res => {
      (res as any).forEach(function (element) {
        element["lable"] = element["dname"];
        element["value"] = element["dname"];
      });
      prioritySelectList.value = res as any;
    });
  }
  if (data == "requestCategoryNo") {
    getCategoryTreeAllData("Request").then(res => {
      // 使用traverseTree遍历树
      traverseTree(res as any, node => {
        node["lable"] = node.attr.cname;
        node["value"] = node.attr.cname;
      });
      let k: any[] = [];
      k.push(res);
      prioritySelectList.value = k;
    });
  }
  if (data == "organizationNos" || data == "technologyGroup") {
    getUserDepartment().then(res => {
      // 使用traverseTree遍历树
      traverseTree(res[0], node => {
        node.lable = node.attr.orgName;
        node.value = node.attr.orgName;
      });
      prioritySelectList.value = res as any;
    });
  }
  if (data == "processKey") {
    findPageProcessDefinitions().then(res => {
      let newres = JSON.parse(JSON.stringify(res));
      (newres.data as any).forEach(function (element) {
        // let tmp={}
        element["lable"] = element["name"];
        element["value"] = element["name"] + "（Ver:" + element["version"] + ")";
      });
      prioritySelectList.value = newres.data as any;
    });
  }
  if (data == "cicategoryNos") {
    getConfigurationCategoryTreeAllData().then(res => {
      // 使用traverseTree遍历树
      traverseTree(res as any, node => {
        node["lable"] = node.attr.cname;
        node["value"] = node.attr.cname;
      });
      prioritySelectList.value = [res as any];
    });
  }

  if (data == "serviceDirIds") {
    getCategoryTreeAllData("Service").then(res => {
      // 使用traverseTree遍历树
      traverseTree(res as any, node => {
        node["lable"] = node.attr.cname;
        node["value"] = node.attr.cname;
      });
      prioritySelectList.value = [res as any];
    });
  }
  if (data == "weekNo") {
    prioritySelectList.value = [
      {
        lable: "星期一",
        value: "星期一"
      },
      {
        lable: "星期二",
        value: "星期二"
      },
      {
        lable: "星期三",
        value: "星期三"
      },
      {
        lable: "星期四",
        value: "星期四"
      },
      {
        lable: "星期五",
        value: "星期五"
      },
      {
        lable: "星期六",
        value: "星期六"
      },
      {
        lable: "星期天",
        value: "星期天"
      }
    ];
  }

  if (data == "locationNos") {
    getCategoryTreeAllData("Location").then(res => {
      // 使用traverseTree遍历树
      traverseTree(res as any, node => {
        node["lable"] = node.attr.cname;
        node["value"] = node.attr.cname;
      });
      prioritySelectList.value = [res as any];
    });
  }
};
const constraintsList = ref<any>([]);
//添加规则
const addRule = async () => {
  //拷贝数据防止指针相同所有数据一起改变 开始
  let tmp = {
    dataType: "String"
  };
  for (let k in constraint) {
    tmp[k] = constraint[k];
  }
  //拷贝数据防止指针相同所有数据一起改变 结束
  if (tmp["beforePropertyName"] == `etitle`) {
    if (tmp["propertyValueName"] == "") {
      ElMessage.error("请选择填写值");
      return;
    }
    tmp["propertyName"] = tmp["beforePropertyName"] + " " + tmp["afterPropertyName"]; //组装propertyName

    tmp.dataType = "String";
    if (tmp["afterPropertyName"] == "matches") {
      tmp["propertyValue"] = ".*" + tmp["propertyValueName"] + ".*";
      tmp["propertyNameLable"] = "标题 包含";
    }
    if (tmp["afterPropertyName"] == "not matches") {
      tmp["propertyValue"] = tmp["propertyValueName"];
      tmp["propertyNameLable"] = "标题 不包含";
    }
    if (tmp["afterPropertyName"] == "==") {
      tmp["propertyValue"] = tmp["propertyValueName"];
      tmp["propertyNameLable"] = "标题 等于";
    }
    if (tmp["afterPropertyName"] == "!=") {
      tmp["propertyValue"] = tmp["propertyValueName"];
      tmp["propertyNameLable"] = "标题 不等于";
    }
    if (tmp["afterPropertyName"] == "matches start") {
      tmp["propertyValue"] = tmp["propertyValueName"] + ".*";
      tmp["propertyNameLable"] = "标题 开始字符";
    }
    if (tmp["afterPropertyName"] == "matches end") {
      tmp["propertyValue"] = ".*" + tmp["propertyValueName"];
      tmp["propertyNameLable"] = "标题 结束字符";
    }
    (constraintsList.value as any).push(tmp);
  }
  if (tmp["beforePropertyName"] == `edesc`) {
    if (tmp["propertyValueName"] == "") {
      ElMessage.error("请选择填写值");
      return;
    }
    tmp["propertyName"] = tmp["beforePropertyName"] + " " + tmp["afterPropertyName"]; //组装propertyName
    tmp.dataType = "String";
    if (tmp["afterPropertyName"] == "matches") {
      tmp["propertyValue"] = ".*" + tmp["propertyValueName"] + ".*";
      tmp["propertyNameLable"] = "描述 包含";
    }
    if (tmp["afterPropertyName"] == "not matches") {
      tmp["propertyValue"] = tmp["propertyValueName"];
      tmp["propertyNameLable"] = "描述 不包含";
    }
    if (tmp["afterPropertyName"] == "==") {
      tmp["propertyValue"] = tmp["propertyValueName"];
      tmp["propertyNameLable"] = "描述 等于";
    }
    if (tmp["afterPropertyName"] == "!=") {
      tmp["propertyValue"] = tmp["propertyValueName"];
      tmp["propertyNameLable"] = "描述 不等于";
    }
    if (tmp["afterPropertyName"] == "matches start") {
      tmp["propertyValue"] = tmp["propertyValueName"] + ".*";
      tmp["propertyNameLable"] = "描述 开始字符";
    }
    if (tmp["afterPropertyName"] == "matches end") {
      tmp["propertyValue"] = ".*" + tmp["propertyValueName"];
      tmp["propertyNameLable"] = "描述 结束字符";
    }
    (constraintsList.value as any).push(tmp);
  }

  if (tmp["beforePropertyName"] == `createdByNo`) {
    tmp.dataType = "Long";
    tmp["propertyName"] = tmp["beforePropertyName"] + " " + tmp["afterPropertyName"]; //组装propertyName
    tmp["propertyNameLable"] = "请求人 " + (tmp["afterPropertyName"] == "in" ? "包含" : "不包含");
    if (tmp["propertyValue"] == "") {
      ElMessage.error("请选择请求人");
      return;
    }
    (constraintsList.value as any).push(tmp);
  }

  if (tmp["beforePropertyName"] == `priorityNo`) {
    tmp.dataType = "Long";
    if (prioritySelectValue.value.length < 0) {
      ElMessage.error("请选择优先级");
      return;
    }
    tmp["propertyValue"] = "";
    tmp["propertyValueName"] = "";
    prioritySelectList.value.forEach(function (element) {
      let newElement = JSON.parse(JSON.stringify(element));
      prioritySelectValue.value.forEach(function (element2) {
        let newElement2 = JSON.parse(JSON.stringify(element2));
        if (newElement.value == newElement2.toString()) {
          if (tmp["propertyValue"] == "") {
            tmp["propertyValue"] = newElement.dcode;
          } else {
            tmp["propertyValue"] += "," + newElement.dcode;
          }
          if (tmp["propertyValueName"] == "") {
            tmp["propertyValueName"] = newElement.dname;
          } else {
            tmp["propertyValueName"] += "," + newElement.dname;
          }
        }
      });
    });

    tmp["propertyName"] = tmp["beforePropertyName"] + " " + tmp["afterPropertyName"]; //组装propertyName
    tmp["propertyNameLable"] = "优先级 " + (tmp["afterPropertyName"] == "in" ? "包含" : "不包含");
    (constraintsList.value as any).push(tmp);
  }

  if (tmp["beforePropertyName"] == `seriousnessNo`) {
    tmp.dataType = "Long";
    if (prioritySelectValue.value.length < 0) {
      ElMessage.error("请选择紧急度");
      return;
    }
    tmp["propertyValue"] = "";
    tmp["propertyValueName"] = "";
    prioritySelectList.value.forEach(function (element) {
      let newElement = JSON.parse(JSON.stringify(element));
      prioritySelectValue.value.forEach(function (element2) {
        let newElement2 = JSON.parse(JSON.stringify(element2));
        if (newElement.value == newElement2.toString()) {
          if (tmp["propertyValue"] == "") {
            tmp["propertyValue"] = newElement.dcode;
          } else {
            tmp["propertyValue"] += "," + newElement.dcode;
          }
          if (tmp["propertyValueName"] == "") {
            tmp["propertyValueName"] = newElement.dname;
          } else {
            tmp["propertyValueName"] += "," + newElement.dname;
          }
        }
      });
    });

    tmp["propertyName"] = tmp["beforePropertyName"] + " " + tmp["afterPropertyName"]; //组装propertyName
    tmp["propertyNameLable"] = "紧急度 " + (tmp["afterPropertyName"] == "in" ? "包含" : "不包含");
    (constraintsList.value as any).push(tmp);
  }

  if (tmp["beforePropertyName"] == `effectRangeNo`) {
    tmp.dataType = "Long";
    if (prioritySelectValue.value.length < 0) {
      ElMessage.error("请选择影响范围");
      return;
    }
    tmp["propertyValue"] = "";
    tmp["propertyValueName"] = "";
    prioritySelectList.value.forEach(function (element) {
      let newElement = JSON.parse(JSON.stringify(element));
      prioritySelectValue.value.forEach(function (element2) {
        let newElement2 = JSON.parse(JSON.stringify(element2));
        if (newElement.value == newElement2.toString()) {
          if (tmp["propertyValue"] == "") {
            tmp["propertyValue"] = newElement.dcode;
          } else {
            tmp["propertyValue"] += "," + newElement.dcode;
          }
          if (tmp["propertyValueName"] == "") {
            tmp["propertyValueName"] = newElement.dname;
          } else {
            tmp["propertyValueName"] += "," + newElement.dname;
          }
        }
      });
    });

    tmp["propertyName"] = tmp["beforePropertyName"] + " " + tmp["afterPropertyName"]; //组装propertyName
    tmp["propertyNameLable"] = "影响范围 " + (tmp["afterPropertyName"] == "in" ? "包含" : "不包含");
    (constraintsList.value as any).push(tmp);
  }
  if (tmp["beforePropertyName"] == `levelNo`) {
    tmp.dataType = "Long";
    if (prioritySelectValue.value.length < 0) {
      ElMessage.error("请选择级别");
      return;
    }
    tmp["propertyValue"] = "";
    tmp["propertyValueName"] = "";
    prioritySelectList.value.forEach(function (element) {
      let newElement = JSON.parse(JSON.stringify(element));
      prioritySelectValue.value.forEach(function (element2) {
        let newElement2 = JSON.parse(JSON.stringify(element2));
        if (newElement.value == newElement2.toString()) {
          if (tmp["propertyValue"] == "") {
            tmp["propertyValue"] = newElement.dcode;
          } else {
            tmp["propertyValue"] += "," + newElement.dcode;
          }
          if (tmp["propertyValueName"] == "") {
            tmp["propertyValueName"] = newElement.dname;
          } else {
            tmp["propertyValueName"] += "," + newElement.dname;
          }
        }
      });
    });
    tmp["propertyName"] = tmp["beforePropertyName"] + " " + tmp["afterPropertyName"]; //组装propertyName
    tmp["propertyNameLable"] = "级别 " + (tmp["afterPropertyName"] == "in" ? "包含" : "不包含");
    (constraintsList.value as any).push(tmp);
  }
  if (tmp["beforePropertyName"] == `imodeNo`) {
    tmp.dataType = "Long";
    if (prioritySelectValue.value.length < 0) {
      ElMessage.error("请选择来源");
      return;
    }
    tmp["propertyValue"] = "";
    tmp["propertyValueName"] = "";
    prioritySelectList.value.forEach(function (element) {
      let newElement = JSON.parse(JSON.stringify(element));
      prioritySelectValue.value.forEach(function (element2) {
        let newElement2 = JSON.parse(JSON.stringify(element2));
        if (newElement.value == newElement2.toString()) {
          if (tmp["propertyValue"] == "") {
            tmp["propertyValue"] = newElement.dcode;
          } else {
            tmp["propertyValue"] += "," + newElement.dcode;
          }
          if (tmp["propertyValueName"] == "") {
            tmp["propertyValueName"] = newElement.dname;
          } else {
            tmp["propertyValueName"] += "," + newElement.dname;
          }
        }
      });
    });
    tmp["propertyName"] = tmp["beforePropertyName"] + " " + tmp["afterPropertyName"]; //组装propertyName
    tmp["propertyNameLable"] = "来源 " + (tmp["afterPropertyName"] == "in" ? "包含" : "不包含");
    (constraintsList.value as any).push(tmp);
  }

  if (tmp["beforePropertyName"] == `requestCategoryNo`) {
    tmp.dataType = "Long";
    if (prioritySelectValue.value.length < 0) {
      ElMessage.error("请选择分类");
      return;
    }
    tmp["propertyValue"] = "";
    tmp["propertyValueName"] = "";
    prioritySelectValue.value.forEach(function (element2) {
      traverseTree(prioritySelectList.value[0], node => {
        if (node.value == element2.toString()) {
          if (tmp["propertyValue"] == "") {
            tmp["propertyValue"] = node.attr.id;
          } else {
            tmp["propertyValue"] += "," + node.attr.id;
          }
          if (tmp["propertyValueName"] == "") {
            tmp["propertyValueName"] = node.attr.cname;
          } else {
            tmp["propertyValueName"] += "," + node.attr.cname;
          }
        }
      });
    });
    tmp["propertyName"] = tmp["beforePropertyName"] + " " + tmp["afterPropertyName"]; //组装propertyName
    tmp["propertyNameLable"] = "分类 " + (tmp["afterPropertyName"] == "in" ? "包含" : "不包含");
    (constraintsList.value as any).push(tmp);
  }

  if (tmp["beforePropertyName"] == `organizationNos`) {
    tmp.dataType = "Long []";
    if (prioritySelectValue.value.length <= 0) {
      ElMessage.error("请选择请求人所属机构");
      return;
    }
    tmp["propertyValue"] = "";
    tmp["propertyValueName"] = "";
    prioritySelectValue.value.forEach(function (element2) {
      traverseTree(prioritySelectList.value[0], node => {
        if (node.value == element2.toString()) {
          if (tmp["propertyValue"] == "") {
            tmp["propertyValue"] = node.attr.orgNo;
          } else {
            tmp["propertyValue"] += "," + node.attr.orgNo;
          }
          if (tmp["propertyValueName"] == "") {
            tmp["propertyValueName"] = node.attr.orgName;
          } else {
            tmp["propertyValueName"] += "," + node.attr.orgName;
          }
        }
      });
    });
    tmp["propertyName"] = tmp["beforePropertyName"] + " " + tmp["afterPropertyName"]; //组装propertyName
    tmp["propertyNameLable"] = "请求人所属机构 " + (tmp["afterPropertyName"] == "in" ? "包含" : "不包含");
    (constraintsList.value as any).push(tmp);
  }

  if (tmp["beforePropertyName"] == `processKey`) {
    tmp.dataType = "String";
    if (prioritySelectValue.value.length <= 0) {
      ElMessage.error("请选择流程");
      return;
    }
    tmp["propertyValue"] = "";
    tmp["propertyValueName"] = "";
    prioritySelectList.value.forEach(function (element) {
      let newElement = JSON.parse(JSON.stringify(element));
      if (newElement.name + "（Ver:" + newElement.version + ")" == prioritySelectValue.value) {
        tmp["propertyValueName"] = prioritySelectValue.value;
        if (tmp["afterPropertyName"] == "matches") {
          tmp["propertyValue"] = ".*" + newElement.id + ".*";
          tmp["propertyNameLable"] = "流程 包含";
        }
        if (tmp["afterPropertyName"] == "not matches") {
          tmp["propertyValue"] = newElement.id;
          tmp["propertyNameLable"] = "流程 不包含";
        }
        if (tmp["afterPropertyName"] == "==") {
          tmp["propertyValue"] = newElement.id;
          tmp["propertyNameLable"] = "流程 等于";
        }
        if (tmp["afterPropertyName"] == "!=") {
          tmp["propertyValue"] = newElement.id;
          tmp["propertyNameLable"] = "流程 不等于";
        }
        if (tmp["afterPropertyName"] == "matches start") {
          tmp["propertyValue"] = newElement.id + ".*";
          tmp["propertyNameLable"] = "流程 开始字符";
        }
        if (tmp["afterPropertyName"] == "matches end") {
          tmp["propertyValue"] = ".*" + newElement.id;
          tmp["propertyNameLable"] = "流程 结束字符";
        }
      }
    });

    tmp["propertyName"] = tmp["beforePropertyName"] + " " + tmp["afterPropertyName"]; //组装propertyName
    tmp["propertyNameLable"] = "流程 " + (tmp["afterPropertyName"] == "in" ? "包含" : "不包含");
    (constraintsList.value as any).push(tmp);
  }

  if (tmp["beforePropertyName"] == `companyNo`) {
    tmp.dataType = "Long";
    tmp["propertyName"] = tmp["beforePropertyName"] + " " + tmp["afterPropertyName"]; //组装propertyName
    tmp["propertyNameLable"] = "请求所属客户 " + (tmp["afterPropertyName"] == "in" ? "包含" : "不包含");
    if (tmp["propertyValue"] == "") {
      ElMessage.error("请选择所属客户");
      return;
    }
    (constraintsList.value as any).push(tmp);
  }

  if (tmp["beforePropertyName"] == `cicategoryNos`) {
    tmp.dataType = "Long []";
    if (prioritySelectValue.value.length <= 0) {
      ElMessage.error("请选择配置项分类");
      return;
    }
    tmp["propertyValue"] = "";
    tmp["propertyValueName"] = "";

    prioritySelectValue.value.forEach(function (element2) {
      traverseTree(prioritySelectList.value[0], node => {
        if (node.value == element2.toString()) {
          if (tmp["propertyValue"] == "") {
            tmp["propertyValue"] = node.attr.cno;
          } else {
            tmp["propertyValue"] += "," + node.attr.cno;
          }
          if (tmp["propertyValueName"] == "") {
            tmp["propertyValueName"] = node.attr.cname;
          } else {
            tmp["propertyValueName"] += "," + node.attr.cname;
          }
        }
      });
    });

    tmp["propertyName"] = tmp["beforePropertyName"] + " " + tmp["afterPropertyName"]; //组装propertyName
    tmp["propertyNameLable"] = "配置项分类 " + (tmp["afterPropertyName"] == "in" ? "包含" : "不包含");
    (constraintsList.value as any).push(tmp);
  }

  if (tmp["beforePropertyName"] == `serviceDirIds`) {
    tmp.dataType = "Long []";
    if (prioritySelectValue.value.length <= 0) {
      ElMessage.error("请选择关联服务");
      return;
    }
    tmp["propertyValue"] = "";
    tmp["propertyValueName"] = "";

    prioritySelectValue.value.forEach(function (element2) {
      traverseTree(prioritySelectList.value[0], node => {
        if (node.data == element2.toString()) {
          if (tmp["propertyValue"] == "") {
            tmp["propertyValue"] = node.attr.id;
          } else {
            tmp["propertyValue"] += "," + node.attr.id;
          }
          if (tmp["propertyValueName"] == "") {
            tmp["propertyValueName"] = node.attr.cname;
          } else {
            tmp["propertyValueName"] += "," + node.attr.cname;
          }
        }
      });
    });

    tmp["propertyName"] = tmp["beforePropertyName"] + " " + tmp["afterPropertyName"]; //组装propertyName
    tmp["propertyNameLable"] = "关联服务 " + (tmp["afterPropertyName"] == "in" ? "包含" : "不包含");
    (constraintsList.value as any).push(tmp);
  }

  if (tmp["beforePropertyName"] == `weekNo`) {
    tmp.dataType = "String []";
    if (prioritySelectValue.value.length <= 0) {
      ElMessage.error("请选择所属星期");
      return;
    }
    tmp["propertyValue"] = "";
    tmp["propertyValueName"] = "";
    prioritySelectValue.value.forEach(function (element2) {
      if (element2.toString() == "星期一") {
        if (tmp["propertyValue"] == "") {
          tmp["propertyValue"] = "Monday";
        } else {
          tmp["propertyValue"] += "," + "Monday";
        }
        if (tmp["propertyValueName"] == "") {
          tmp["propertyValueName"] = "星期一";
        } else {
          tmp["propertyValueName"] += "," + "星期一";
        }
      } else if (element2.toString() == "星期二") {
        if (tmp["propertyValue"] == "") {
          tmp["propertyValue"] = "Tuesday";
        } else {
          tmp["propertyValue"] += "," + "Tuesday";
        }
        if (tmp["propertyValueName"] == "") {
          tmp["propertyValueName"] = "星期二";
        } else {
          tmp["propertyValueName"] += "," + "星期二";
        }
      } else if (element2.toString() == "星期三") {
        if (tmp["propertyValue"] == "") {
          tmp["propertyValue"] = "Wednesday";
        } else {
          tmp["propertyValue"] += "," + "Wednesday";
        }
        if (tmp["propertyValueName"] == "") {
          tmp["propertyValueName"] = "星期三";
        } else {
          tmp["propertyValueName"] += "," + "星期三";
        }
      } else if (element2.toString() == "星期四") {
        if (tmp["propertyValue"] == "") {
          tmp["propertyValue"] = "Thursday";
        } else {
          tmp["propertyValue"] += "," + "Thursday";
        }
        if (tmp["propertyValueName"] == "") {
          tmp["propertyValueName"] = "星期四";
        } else {
          tmp["propertyValueName"] += "," + "星期四";
        }
      } else if (element2.toString() == "星期五") {
        if (tmp["propertyValue"] == "") {
          tmp["propertyValue"] = "Friday";
        } else {
          tmp["propertyValue"] += "," + "Friday";
        }
        if (tmp["propertyValueName"] == "") {
          tmp["propertyValueName"] = "星期五";
        } else {
          tmp["propertyValueName"] += "," + "星期五";
        }
      } else if (element2.toString() == "星期六") {
        if (tmp["propertyValue"] == "") {
          tmp["propertyValue"] = "Saturday";
        } else {
          tmp["propertyValue"] += "," + "Saturday";
        }
        if (tmp["propertyValueName"] == "") {
          tmp["propertyValueName"] = "星期六";
        } else {
          tmp["propertyValueName"] += "," + "星期六";
        }
      } else if (element2.toString() == "星期天") {
        if (tmp["propertyValue"] == "") {
          tmp["propertyValue"] = "Sunday";
        } else {
          tmp["propertyValue"] += "," + "Sunday";
        }
        if (tmp["propertyValueName"] == "") {
          tmp["propertyValueName"] = "星期天";
        } else {
          tmp["propertyValueName"] += "," + "星期天";
        }
      } else {
      }
    });
    tmp["propertyName"] = tmp["beforePropertyName"] + " " + tmp["afterPropertyName"]; //组装propertyName
    tmp["propertyNameLable"] = "所属星期 " + (tmp["afterPropertyName"] == "in" ? "包含" : "不包含");
    (constraintsList.value as any).push(tmp);
  }

  if (tmp["beforePropertyName"] == `technologyGroup`) {
    tmp.dataType = "Long []";
    if (prioritySelectValue.value.length < 0) {
      ElMessage.error("请选择所属技术组");
      return;
    }
    tmp["propertyValue"] = "";
    tmp["propertyValueName"] = "";
    prioritySelectValue.value.forEach(function (element2) {
      traverseTree(prioritySelectList.value[0], node => {
        if (node.value == element2.toString()) {
          if (tmp["propertyValue"] == "") {
            tmp["propertyValue"] = node.attr.orgNo;
          } else {
            tmp["propertyValue"] += "," + node.attr.orgNo;
          }
          if (tmp["propertyValueName"] == "") {
            tmp["propertyValueName"] = node.attr.orgName;
          } else {
            tmp["propertyValueName"] += "," + node.attr.orgName;
          }
        }
      });
    });

    tmp["propertyName"] = tmp["beforePropertyName"] + " " + tmp["afterPropertyName"]; //组装propertyName
    tmp["propertyNameLable"] = "请求人所属技术组 " + (tmp["afterPropertyName"] == "in" ? "包含" : "不包含");
    (constraintsList.value as any).push(tmp);
  }

  if (tmp["beforePropertyName"] == `locationNos`) {
    tmp.dataType = "Long";
    if (prioritySelectValue.value.length <= 0) {
      ElMessage.error("请选择地点");
      return;
    }
    tmp["propertyValue"] = "";
    tmp["propertyValueName"] = "";

    prioritySelectValue.value.forEach(function (element2) {
      traverseTree(prioritySelectList.value[0], node => {
        if (node.value == element2.toString()) {
          if (tmp["propertyValue"] == "") {
            tmp["propertyValue"] = node.attr.id;
          } else {
            tmp["propertyValue"] += "," + node.attr.id;
          }
          if (tmp["propertyValueName"] == "") {
            tmp["propertyValueName"] = node.attr.cname;
          } else {
            tmp["propertyValueName"] += "," + node.attr.cname;
          }
        }
      });
    });
    tmp["propertyName"] = tmp["beforePropertyName"] + " " + tmp["afterPropertyName"]; //组装propertyName
    tmp["propertyNameLable"] = "地点 " + (tmp["afterPropertyName"] == "in" ? "包含" : "不包含");
    (constraintsList.value as any).push(tmp);
  }
  console.log(constraintsList.value);
};
//
const saveRule = async () => {
  if (!name.value) {
    ElMessage.error("名称不能为空");
    return;
  }
  if (!salience.value) {
    ElMessage.error("执行次数不能为空");
    return;
  }
  if (!description.value) {
    ElMessage.error("规则描述不能为空");
    return;
  }
  if (!packageName.value) {
    ElMessage.error("规则包不能为空");
    return;
  }
  if (constraintsList.value.length === 0) {
    ElMessage.error("条件集不能为空");
    return;
  }
  if (actionList.value.length === 0) {
    ElMessage.error("动作集不能为空");
    return;
  }
  let rule = {
    actions: [] as Array<{ propertyName: string; givenValue: string; givenName: string; dataType: string; sequence: number }>,
    condition: {
      constraints: [] as Array<{
        conNo: string;
        propertyName: string;
        propertyValue: string;
        propertyValueName: string;
        dataType: string;
        andOr: string;
        sequence: number;
      }>
    }
  };
  actionList.value.forEach((element, i) => {
    // 确保 rule.actions[i] 是一个对象
    rule.actions[i] = {
      propertyName: "",
      givenValue: "",
      givenName: "",
      dataType: "",
      sequence: 0
    };
    rule.actions[i].propertyName = element.propertyName;
    rule.actions[i].givenValue = element.givenValue;
    rule.actions[i].givenName = element.givenName;
    rule.actions[i].dataType = element.dataType;
    rule.actions[i].sequence = element.sequence;
  });
  constraintsList.value.forEach((element, i) => {
    rule.condition.constraints[i] = {
      conNo: "",
      propertyName: "",
      propertyValue: "",
      propertyValueName: "",
      dataType: "",
      andOr: "",
      sequence: 0
    };
    rule.condition.constraints[i].conNo = element.conNo;
    rule.condition.constraints[i].propertyName = element.propertyName;
    rule.condition.constraints[i].propertyValue = element.propertyValue;
    rule.condition.constraints[i].propertyValueName = element.propertyValueName;
    rule.condition.constraints[i].dataType = element.dataType;
    rule.condition.constraints[i].andOr = element.andOr;
    rule.condition.constraints[i].sequence = element.sequence;
  });
  let ruleParams = {
    "rule.dialect": "mvel",
    "rule.condition.patternBinding": "dto",
    "rule.condition.patternType": "RequestDTO",
    "rule.condition.rulePatternNo": rulePatternNo.value,
    "rule.ruleNo": route.query.ruleNo,
    "rule.ruleName": name.value,
    "rule.salience": salience.value,
    "rule.description": description.value,
    "rule.rulePackage.rulePackageNo": packageNo.value
    // "rule.condition.constraints": rule.condition.constraints
  };
  rule.actions.map((d, i) => {
    for (let key in d) {
      if (d.hasOwnProperty(key)) {
        const newKey = `rule.actions[${i}].${key}`;
        ruleParams[newKey] = d[key];
      }
    }
  });
  rule.condition.constraints.map((d, i) => {
    for (let key in d) {
      if (d.hasOwnProperty(key)) {
        const newKey = `rule.condition.constraints[${i}].${key}`;
        ruleParams[newKey] = d[key];
      }
    }
  });
  const data = await saveUpdateRule(ruleParams);
  if (JSON.stringify(data).includes("规则列表")) {
    ElMessage.success("添加成功");
    router.push(`/business/rules/requestRules`);
  }
  // const check = await checkRuleName(checkPamas);
  // if ((check as any) === false) {
  //   const data = await saveUpdateRule(ruleParams);
  //   if (JSON.stringify(data).includes("规则列表")) {
  //     ElMessage.success("添加成功");
  //     router.push(`/business/rules/requestRules`);
  //   }
  // } else {
  //   ElMessage.error("规则已存在，请重新修改名称");
  //   return;
  // }
};
//动作集
//动作集类型
const executeAction = [
  { name: "设置服务机构", value: "servicesNo" },
  { name: "设置审批人", value: "approvalNo" },
  { name: "升级到", value: "updateLevelNo" },
  { name: "指派工作组", value: "assigneeGroupNo" },
  { name: "指派工程师", value: "technicianNo" },
  { name: "设置优先级", value: "priorityNo" },
  { name: "设置紧急度", value: "seriousnessNo" },
  { name: "设置影响范围", value: "effectRangeNo" },
  { name: "设置流程", value: "processKey" },
  { name: "设置分类", value: "requestCategoryNo" },
  { name: "关联服务", value: "serviceDirIdsStr" },
  { name: "匹配SLA", value: "slaContractNo" },
  { name: "安排排班处理", value: "attendance" },
  { name: "根据繁忙度自动指派技术员", value: "automaticallyAssigned" },
  { name: "变量指派", value: "variablesAssigneeType" },
  { name: "关闭请求", value: "requestClose" }
];
const SLA = reactive({
  SLAName: "",
  SLAId: ""
});
const slaDialog = ref(false);
//
const props1 = {
  checkStrictly: true,
  label: "data",
  value: "attr"
};
//请求分类
const props2 = {
  checkStrictly: true,
  label: "data",
  value: "attr"
};
const getVal = value => {
  console.log(value[value.length - 1]);
};
const orgName = ref<any>([]);
const requestType = ref<any>([]);
const orgList = ref<any>([]);
const actionType = ref("");
const approval = reactive({
  name: "",
  userId: ""
});
const selectText = ref("");
const selectValue = ref<any>([]);
const SLAList = ref<any>([]);
const chooseSLA = i => {
  console.log(i.row);
  SLA.SLAName = i.row.agreement;
  SLA.SLAId = i.row.rulePackageNo;
  slaDialog.value = false;
};
const selectActionType = async (data: string) => {
  console.log(data);
  if (data === "servicesNo") {
    actionType.value = "servicesNo";
    orgList.value = [];
    const list = await getUserDepartment();
    orgList.value = list[0].children[1].children;
  }
  if (data == "approvalNo") {
    actionType.value = "approvalNo";
  }
  if (data === "updateLevelNo") {
    actionType.value = "updateLevelNo";
    selectValue.value = [];
    selectText.value = "";
    const res = await getUpgradeUserList();
    (res.data as any).forEach(item => {
      selectValue.value.push({
        name: item.approvalName,
        value: item.approvalNo
      });
    });
  }
  if (data === "assigneeGroupNo") {
    actionType.value = "assigneeGroupNo";
    orgList.value = [];
    const list = await getUserDepartment();
    orgList.value = list[0].children[1].children;
  }
  if (data === "technicianNo") {
    actionType.value = "technicianNo";
  }
  if (data === "priorityNo") {
    actionType.value = "priorityNo";
    selectValue.value = [];
    selectText.value = "";
    const res = await getPriority();
    (res as any).forEach(item => {
      selectValue.value.push({
        name: item.dname,
        value: item.dcode
      });
    });
  }
  if (data === "seriousnessNo") {
    actionType.value = "seriousnessNo";
    selectValue.value = [];
    selectText.value = "";
    const res = await getUrgency();
    (res as any).forEach(item => {
      selectValue.value.push({
        name: item.dname,
        value: item.dcode
      });
    });
  }
  if (data === "effectRangeNo") {
    actionType.value = "effectRangeNo";
    selectValue.value = [];
    selectText.value = "";
    const res = await getImpact();
    (res as any).forEach(item => {
      selectValue.value.push({
        name: item.dname,
        value: item.dcode
      });
    });
  }
  if (data === "processKey") {
    actionType.value = "processKey";
    selectValue.value = [];
    selectText.value = "";
    const res = await getProcess();
    (res.data as any).forEach(item => {
      if (item.name.indexOf("request") != -1) {
        selectValue.value.push({
          name: item.name + "(Ver:" + item.version + ")",
          value: item.key
        });
      }
    });
  }
  if (data === "requestCategoryNo") {
    actionType.value = "requestCategoryNo";
    orgList.value = [];
    const res = await getClassification();
    orgList.value.push(res);
  }
  if (data === "serviceDirIdsStr") {
    actionType.value = "serviceDirIdsStr";
    orgList.value = [];
    const res = await getServiceCatalog({
      types: "Service",
      parentEventId: 0
    });
    orgList.value.push(res);
  }
  if (data === "slaContractNo") {
    actionType.value = "slaContractNo";
    let orgNo: any;
    let slaParams = "";
    if (constraintsList.value.length === 0) {
      return;
    } else {
      constraintsList.value.forEach(item => {
        if (item.propertyNameLable.indexOf("请求人所属机构") != -1) {
          orgNo = item.propertyValue.split(",");
          orgNo.forEach(item => {
            slaParams += "qdto.orgNos=" + item + "&";
          });
          getSLAList(slaParams).then(res => {
            SLAList.value = res.data;
          });
        } else {
          return;
        }
      });
    }
  }
  if (data === "attendance") {
    actionType.value = "attendance";
    selectValue.value = [];
    selectText.value = "";
    selectValue.value = [
      { name: "是", value: true },
      { name: "否", value: false }
    ];
  }
  if (data === "automaticallyAssigned") {
    actionType.value = "automaticallyAssigned";
    selectValue.value = [];
    selectText.value = "";
    selectValue.value = [
      { name: "是", value: true },
      { name: "否", value: false }
    ];
  }
  if (data === "variablesAssigneeType") {
    actionType.value = "variablesAssigneeType";
    selectValue.value = [];
    selectText.value = "";
    selectValue.value = [
      { name: "请求人", value: "creator" },
      { name: "现指派的技术员", value: "technician" },
      { name: "指派组的负责人", value: "groupHead" },
      { name: "请求人所属机构第一层负责人", value: "leader_0" },
      { name: "请求人所属机构第二层负责人", value: "leader_1" },
      { name: "请求人所属机构第三层负责人", value: "leader_2" },
      { name: "请求人所属机构第四层负责人", value: "leader_3" }
    ];
  }
  if (data === "requestClose") {
    actionType.value = "requestClose";
    selectValue.value = [];
    selectText.value = "";
    selectValue.value = [
      { name: "是", value: true },
      { name: "否", value: false }
    ];
  }
};
//动作集表格数据
const actionList = ref<any>([]);
//添加动作及
let sequence = 0;
const addAction = () => {
  sequence = sequence + 1;
  let actions = {
    propertyNameLable: "",
    propertyName: "",
    givenValue: "",
    givenName: "",
    dataType: "",
    sequence: sequence
  };
  if (actionType.value === "servicesNo") {
    (actions["propertyName"] = "servicesNo"),
      (actions["propertyNameLable"] = "设置服务机构"),
      (actions["givenName"] = orgName.value[orgName.value.length - 1].orgName),
      (actions["givenValue"] = orgName.value[orgName.value.length - 1].orgNo),
      (actions["dataType"] = "Long"),
      (actions["sequence"] = sequence);
    if (actionList.value.length !== 0) {
      actionList.value.map(item => {
        if (item.propertyNameLable !== "" && item.propertyNameLable === "设置服务机构") {
          ElMessage.error("动作类型重复，请先删除原来数据");
          return;
        } else {
          actionList.value.push(actions);
        }
      });
    } else {
      actionList.value.push(actions);
    }
  }
  if (actionType.value === "approvalNo") {
    (actions["propertyName"] = "approvalNo"),
      (actions["propertyNameLable"] = "设置服务机构审批人"),
      (actions["givenName"] = approval.name),
      (actions["givenValue"] = approval.userId),
      (actions["dataType"] = "Long"),
      (actions["sequence"] = sequence);
    if (actionList.value.length !== 0) {
      actionList.value.map(item => {
        if (item.propertyNameLable !== "" && item.propertyNameLable === "设置服务机构审批人") {
          ElMessage.error("动作类型重复，请先删除原来数据");
          return;
        } else {
          actionList.value.push(actions);
        }
      });
    } else {
      actionList.value.push(actions);
    }
  }
  if (actionType.value === "updateLevelNo") {
    (actions["propertyName"] = "updateLevelNo"),
      (actions["propertyNameLable"] = "升级到"),
      (actions["givenName"] = selectedText.value),
      (actions["givenValue"] = selectText.value),
      (actions["dataType"] = "Long"),
      (actions["sequence"] = sequence);
    if (actionList.value.length !== 0) {
      actionList.value.map(item => {
        if (item.propertyNameLable !== "" && item.propertyNameLable === "升级到") {
          ElMessage.error("动作类型重复，请先删除原来数据");
          return;
        } else {
          actionList.value.push(actions);
        }
      });
    } else {
      actionList.value.push(actions);
    }
  }
  if (actionType.value === "assigneeGroupNo") {
    (actions["propertyName"] = "assigneeGroupNo"),
      (actions["propertyNameLable"] = "指派到工作组"),
      (actions["givenName"] = orgName.value[orgName.value.length - 1].orgName),
      (actions["givenValue"] = orgName.value[orgName.value.length - 1].orgNo),
      (actions["dataType"] = "Long"),
      (actions["sequence"] = sequence);
    if (actionList.value.length !== 0) {
      actionList.value.map(item => {
        if (item.propertyNameLable !== "" && item.propertyNameLable === "指派到工作组") {
          ElMessage.error("动作类型重复，请先删除原来数据");
          return;
        } else {
          actionList.value.push(actions);
        }
      });
    } else {
      actionList.value.push(actions);
    }
  }
  if (actionType.value === "technicianNo") {
    (actions["propertyName"] = "technicianNo"),
      (actions["propertyNameLable"] = "指派到工程师"),
      (actions["givenName"] = approval.name),
      (actions["givenValue"] = approval.userId),
      (actions["dataType"] = "Long"),
      (actions["sequence"] = sequence);
    if (actionList.value.length !== 0) {
      actionList.value.map(item => {
        if (item.propertyNameLable !== "" && item.propertyNameLable === "指派到工程师") {
          ElMessage.error("动作类型重复，请先删除原来数据");
          return;
        } else {
          actionList.value.push(actions);
        }
      });
    } else {
      actionList.value.push(actions);
    }
  }
  if (actionType.value === "priorityNo") {
    (actions["propertyName"] = "priorityNo"),
      (actions["propertyNameLable"] = "设置优先级"),
      (actions["givenName"] = selectedText.value),
      (actions["givenValue"] = selectText.value),
      (actions["dataType"] = "Long"),
      (actions["sequence"] = sequence);
    if (actionList.value.length !== 0) {
      actionList.value.map(item => {
        if (item.propertyNameLable !== "" && item.propertyNameLable === "设置优先级") {
          ElMessage.error("动作类型重复，请先删除原来数据");
          return;
        } else {
          actionList.value.push(actions);
        }
      });
    } else {
      actionList.value.push(actions);
    }
  }
  if (actionType.value === "seriousnessNo") {
    (actions["propertyName"] = "seriousnessNo"),
      (actions["propertyNameLable"] = "设置紧急度"),
      (actions["givenName"] = selectedText.value),
      (actions["givenValue"] = selectText.value),
      (actions["dataType"] = "Long"),
      (actions["sequence"] = sequence);
    if (actionList.value.length !== 0) {
      actionList.value.map(item => {
        if (item.propertyNameLable !== "" && item.propertyNameLable === "设置紧急度") {
          ElMessage.error("动作类型重复，请先删除原来数据");
          return;
        } else {
          actionList.value.push(actions);
        }
      });
    } else {
      actionList.value.push(actions);
    }
  }
  if (actionType.value === "effectRangeNo") {
    (actions["propertyName"] = "effectRangeNo"),
      (actions["propertyNameLable"] = "设置影响范围"),
      (actions["givenName"] = selectedText.value),
      (actions["givenValue"] = selectText.value),
      (actions["dataType"] = "Long"),
      (actions["sequence"] = sequence);
    if (actionList.value.length !== 0) {
      actionList.value.map(item => {
        if (item.propertyNameLable !== "" && item.propertyNameLable === "设置影响范围") {
          ElMessage.error("动作类型重复，请先删除原来数据");
          return;
        } else {
          actionList.value.push(actions);
        }
      });
    } else {
      actionList.value.push(actions);
    }
  }
  if (actionType.value === "processKey") {
    (actions["propertyName"] = "processKey"),
      (actions["propertyNameLable"] = "设置流程"),
      (actions["givenName"] = selectedText.value),
      (actions["givenValue"] = selectText.value),
      (actions["dataType"] = "Long"),
      (actions["sequence"] = sequence);
    if (actionList.value.length !== 0) {
      actionList.value.map(item => {
        if (item.propertyNameLable !== "" && item.propertyNameLable === "设置流程") {
          ElMessage.error("动作类型重复，请先删除原来数据");
          return;
        } else {
          actionList.value.push(actions);
        }
      });
    } else {
      actionList.value.push(actions);
    }
  }
  if (actionType.value === "requestCategoryNo") {
    (actions["propertyName"] = "requestCategoryNo"),
      (actions["propertyNameLable"] = "设置分类"),
      (actions["givenName"] = requestType.value[requestType.value.length - 1].cname),
      (actions["givenValue"] = requestType.value[requestType.value.length - 1].id),
      (actions["dataType"] = "Long"),
      (actions["sequence"] = sequence);
    if (actionList.value.length !== 0) {
      actionList.value.map(item => {
        if (item.propertyNameLable !== "" && item.propertyNameLable === "设置分类") {
          ElMessage.error("动作类型重复，请先删除原来数据");
          return;
        } else {
          actionList.value.push(actions);
        }
      });
    } else {
      actionList.value.push(actions);
    }
  }
  if (actionType.value === "serviceDirIdsStr") {
    (actions["propertyName"] = "serviceDirIdsStr"),
      (actions["propertyNameLable"] = "关联服务"),
      (actions["givenName"] = requestType.value[requestType.value.length - 1].cname),
      (actions["givenValue"] = requestType.value[requestType.value.length - 1].id),
      (actions["dataType"] = "Long"),
      (actions["sequence"] = sequence);
    if (actionList.value.length !== 0) {
      actionList.value.map(item => {
        if (item.propertyNameLable !== "" && item.propertyNameLable === "关联服务") {
          ElMessage.error("动作类型重复，请先删除原来数据");
          return;
        } else {
          actionList.value.push(actions);
        }
      });
    } else {
      actionList.value.push(actions);
    }
  }
  if (actionType.value === "slaContractNo") {
    (actions["propertyName"] = "slaContractNo"),
      (actions["propertyNameLable"] = "匹配SLA"),
      (actions["givenName"] = SLA.SLAName),
      (actions["givenValue"] = SLA.SLAId),
      (actions["dataType"] = "Long"),
      (actions["sequence"] = sequence);
    if (actionList.value.length !== 0) {
      actionList.value.map(item => {
        if (item.propertyNameLable !== "" && item.propertyNameLable === "匹配SLA") {
          ElMessage.error("动作类型重复，请先删除原来数据");
          return;
        } else {
          actionList.value.push(actions);
        }
      });
    } else {
      actionList.value.push(actions);
    }
  }
  if (actionType.value === "attendance") {
    (actions["propertyName"] = "attendance"),
      (actions["propertyNameLable"] = "安排排班处理"),
      (actions["givenName"] = selectedText.value),
      (actions["givenValue"] = selectText.value),
      (actions["dataType"] = "Long"),
      (actions["sequence"] = sequence);
    if (actionList.value.length !== 0) {
      actionList.value.map(item => {
        if (item.propertyNameLable !== "" && item.propertyNameLable === "安排排班处理") {
          ElMessage.error("动作类型重复，请先删除原来数据");
          return;
        } else {
          actionList.value.push(actions);
        }
      });
    } else {
      actionList.value.push(actions);
    }
  }
  if (actionType.value === "automaticallyAssigned") {
    (actions["propertyName"] = "automaticallyAssigned"),
      (actions["propertyNameLable"] = "根据繁忙程度自动指派技术员"),
      (actions["givenName"] = selectedText.value),
      (actions["givenValue"] = selectText.value),
      (actions["dataType"] = "Long"),
      (actions["sequence"] = sequence);
    if (actionList.value.length !== 0) {
      actionList.value.map(item => {
        if (item.propertyNameLable !== "" && item.propertyNameLable === "根据繁忙度自动指派技术员") {
          ElMessage.error("动作类型重复，请先删除原来数据");
          return;
        } else {
          actionList.value.push(actions);
        }
      });
    } else {
      actionList.value.push(actions);
    }
  }
  if (actionType.value === "variablesAssigneeType") {
    (actions["propertyName"] = "variablesAssigneeType"),
      (actions["propertyNameLable"] = "变量指派"),
      (actions["givenName"] = selectedText.value),
      (actions["givenValue"] = selectText.value),
      (actions["dataType"] = "Long"),
      (actions["sequence"] = sequence);
    if (actionList.value.length !== 0) {
      actionList.value.map(item => {
        if (item.propertyNameLable !== "" && item.propertyNameLable === "变量指派") {
          ElMessage.error("动作类型重复，请先删除原来数据");
          return;
        } else {
          actionList.value.push(actions);
        }
      });
    } else {
      actionList.value.push(actions);
    }
  }
  if (actionType.value === "requestClose") {
    (actions["propertyName"] = "requestClose"),
      (actions["propertyNameLable"] = "关闭请求"),
      (actions["givenName"] = selectedText.value),
      (actions["givenValue"] = selectText.value),
      (actions["dataType"] = "Long"),
      (actions["sequence"] = sequence);
    if (actionList.value.length !== 0) {
      actionList.value.map(item => {
        if (item.propertyNameLable !== "" && item.propertyNameLable === "关闭请求") {
          ElMessage.error("动作类型重复，请先删除原来数据");
          return;
        } else {
          actionList.value.push(actions);
        }
      });
    } else {
      actionList.value.push(actions);
    }
  }
  console.log(actionList.value);
};
const selectedText = ref("");
const selectTextChange = val => {
  const selectedOption = selectValue.value.find(option => option.value === selectText.value);
  selectedText.value = selectedOption ? selectedOption.name : "";
};
</script>
<style lang="scss" scoped>
.main {
  display: flex;
  width: 100%;
  height: 90%;
  margin-top: 20px;
  .base {
    width: 30%;
    height: 100%;
    padding: 0 20px;
    margin-right: 40px;
    background-color: #ffffff;
  }
  .detailInfo {
    width: 68%;
    height: 100%;
    padding: 0 20px;
    background-color: #ffffff;
  }
}
</style>
